% -------------------------------------------------------------------------
% plot Earth and Moon under Earth-Moon rotating frame
% 
% Copyright(C) 2015/06/30 by Chen Zhang, 
% School of Astronautics, Beihang University
% chenzhang.buaa@gmail.com
% -------------------------------------------------------------------------
function em_rot
mu = 0.0121506683; % 
l_ref = 384405; % [km]
Re = 6378; % Earth radius
Rm = 1737; % Moon radius
hi = 167; % orbit altitude of Earth parking orbit
hf = 100; % orbit altitude of Moon working orbit
ri = (Re + hi) / l_ref; % Radial distance of Earth parking orbit
rf = (Rm + hf) / l_ref; % Radial distance of Moon working orbit
% plot Earth and Moon
[xs ys zs] = sphere(10) ;
surf(-mu+xs*Re/l_ref,  ys*Re/l_ref, zs*Re/l_ref, 'FaceColor', 'w') ; hold on;
surf(1-mu+xs*Rm/l_ref, ys*Rm/l_ref, zs*Rm/l_ref, 'FaceColor', 'w') ; hold on;
angle = 0 : 0.05 : 2*pi + 0.05; 
% plot Earth parking orbit
plot(-mu + ri*cos(angle), ri*sin(angle), 'k-.') ; hold on;
% plot Moon working orbit
plot(1-mu + rf*cos(angle), rf*sin(angle), 'k-.') ; hold on;
axis equal;
grid off;
end
% -------------------------------------------------------------------------
